
		**********************************************************
		** File: cleaning_polity.do								**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning Polity IV								**
 		**********************************************************

 

	clear
	version 16.0
	set more off

	* data source: https://www.systemicpeace.org/inscrdata.html
	
	import excel "p4v2018.xls", sheet("p4v2017") firstrow case(lower) clear

	drop cyear
	sort ccode year
	label var democ "Democracy 10-pt score (Polity IV)"
	label var autoc "Autocracy 10-pt score (Polity IV)"
	label var polity "Polity Combined democracy-autocracy score -10 to +10 annual"
	label var polity2 "Polity Combined 20-pt score with mean subs for special polity conditions (Polity"
	label var durable "Number of years since the last regime transition (3pt or greater)"
	label var xrreg "Regulation of executive recruitment (Polity IV)"
	label var xrcomp "Competitiveness of executive recruitment (Polity IV)"
	label var xropen "Openness of executive recruitment (Polity IV)"
	label var xconst "Executive constraints (Polity IV)"
	label var parreg "Regulation of participation  (Polity IV)"
	label var parcomp "Parliamentary competition (Polity IV)"
	label var exrec "Executive recruitment (combined XRReg, XRComp, XROpen)"
	label var exconst "Executive constraints (Polity IV)"
	label var polcomp " Political competition (ParReg+ParComp)(Polity IV)"
	label var regtrans "Type of regime change (Polity IV)"

	keep country ccode year democ autoc polity polity2 durable xrreg xrcomp xropen xconst ///
		 parreg parcomp exrec exconst polcomp
		 
	 ** CORRECTING ccodes ***
	 
	** VIETNAM **
	replace ccode=816 if ccode==818	 

	** Ethiopia **
	replace ccode=530 if ccode==529
	
	** South Sudan 
	replace ccode=626 if ccode==525
	
	duplicates report ccode year
 
	drop if country=="Ethiopia" & year==1993 & polity2==0
	drop if country=="Vietnam North" & year==1976
	drop if country=="Sudan-North" & year==2011
	
	replace ccode=625 if country=="Sudan-North"
	replace country="Sudan" if country=="Sudan-North"
	
	sort ccode year
 
	save "Polity 2018.dta", replace
